﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Estimate.Common.Estimate;
using Estimate.Common.DBFieldTypes;

namespace Estimate.Reports
{

    public class IndividualCityScoreComparer_RecordCount : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((int)x.Value["RecordCount"] - (int)y.Value["RecordCount"]);
        }
    }

    public class IndividualCityScoreComparer_WaterSkill : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["FD24_Water_Skill"] - (float)y.Value["FD24_Water_Skill"]);
        }
    }

    public class IndividualCityScoreComparer_MaxTSkill : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["FD24_MaxT_Skill"] - (float)y.Value["FD24_MaxT_Skill"]);
        }
    }

    public class IndividualCityScoreComparer_MinTSkill : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["FD24_MinT_Skill"] - (float)y.Value["FD24_MinT_Skill"]);
        }
    }

    /* 降水 */
    public class IndividualCityScoreComparer_WaterScore : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["MixPC"] - (float)y.Value["MixPC"]);
        }
    }

    /* 最高温 */
    public class IndividualCityScoreComparer_MaxTScore : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["MixMaxTt2"] - (float)y.Value["MixMaxTt2"]);
        }
    }

    //最低温
    public class IndividualCityScoreComparer_MinTScore : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            return Math.Sign((float)x.Value["MixMinTt2"] - (float)y.Value["MixMinTt2"]);
        }
    }

    public class IndividualCityScoreComparer_SumOrder : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        public int Compare(KeyValuePair<string, Dictionary<string, object>> x, KeyValuePair<string, Dictionary<string, object>> y)
        {
            return Math.Sign((float)x.Value["SumOrder"] - (float)y.Value["SumOrder"]);
        }
    }

    public class IndividualCityScoreComparer_MaxTemp : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        ForeSpanType Span;

        public IndividualCityScoreComparer_MaxTemp(ForeSpanType span)
        {
            Span = span;
        }

        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            TempScore tempScoreX = ((Dictionary<ForeSpanType, TempScore>)x.Value["max"])[Span];
            TempScore tempScoreY = ((Dictionary<ForeSpanType, TempScore>)y.Value["max"])[Span];

            return Math.Sign(tempScoreX.Tt2 - tempScoreY.Tt2);
        }
    }

    public class IndividualCityScoreComparer_MinTemp : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        ForeSpanType Span;

        public IndividualCityScoreComparer_MinTemp(ForeSpanType span)
        {
            Span = span;
        }

        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            TempScore tempScoreX = ((Dictionary<ForeSpanType, TempScore>)x.Value["min"])[Span];
            TempScore tempScoreY = ((Dictionary<ForeSpanType, TempScore>)y.Value["min"])[Span];

            return Math.Sign(tempScoreX.Tt2 - tempScoreY.Tt2);
        }
    }

    public class IndividualCityScoreComparer_WaterfallAmount : IComparer<KeyValuePair<string, Dictionary<string, object>>>
    {
        ForeSpanType Span;

        public IndividualCityScoreComparer_WaterfallAmount(ForeSpanType span)
        {
            Span = span;
        }

        public int Compare(KeyValuePair<string, Dictionary<string, object>> y, KeyValuePair<string, Dictionary<string, object>> x)
        {
            WaterScore waterScoreX = ((Dictionary<ForeSpanType, WaterScore>)x.Value["wth"])[Span];
            WaterScore waterScoreY = ((Dictionary<ForeSpanType, WaterScore>)y.Value["wth"])[Span];

            return Math.Sign(waterScoreX.PC - waterScoreY.PC);
        }
    }

    public class IndividualCompositeScore : IComparer<ForecasterScore>
    {
        public int Compare(ForecasterScore y, ForecasterScore x)
        {
            return Math.Sign(x.Composite - y.Composite);
        }
    }

    public class ForecasterCompositeScore : IComparer<Dictionary<string, object>>
    {
        string key;
        public ForecasterCompositeScore(string Key)
        {
            key = Key;
        }

        public int Compare(Dictionary<string, object> y, Dictionary<string, object> x)
        {
            return Math.Sign((float)x[key] - (float)y[key]);
        }
    }

    public class StationCompositeScore : IComparer<Dictionary<string, object>>
    {
        string key;
        public StationCompositeScore(string Key)
        {
            key = Key;
        }

        public int Compare(Dictionary<string, object> y, Dictionary<string, object> x)
        {
            return Math.Sign((float)x[key] - (float)y[key]);
        }
    }

    public class UsuallyReportCompositeScore : IComparer<UsuallyReport_CityScore>
    {
        public int Compare(UsuallyReport_CityScore y, UsuallyReport_CityScore x)
        {
            return Math.Sign(x.value - y.value);
        }
    }

}
